﻿<%@ Control Language="C#" AutoEventWireup="true" CodeFile="CategorybyTreeView.ascx.cs"
    Inherits="Controls_CategorybyTreeView" %>
<h3>
    Refine your results</h3>
<div class="content">
    <h4>
        Categories</h4>
    <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl="~/search.aspx">All categories</asp:HyperLink>
    <asp:Repeater ID="ReTreeView" runat="server" DataSourceID="CategoryDataSource" 
        onitemdatabound="ReTreeView_ItemDataBound" 
        onitemcommand="ReTreeView_ItemCommand">
        <HeaderTemplate>
            <ul class='treeview'>
        </HeaderTemplate>        
        <ItemTemplate>
            <asp:Literal runat="server" ID="htmlItem" Text="" />
            <asp:LinkButton ID="lnkCatChange" runat="server" CssClass="hidden" CommandName="categoryChanged"></asp:LinkButton>
        </ItemTemplate>
        <FooterTemplate>
            </ul>
        </FooterTemplate>
    </asp:Repeater>
</div>
<script language="javascript">
jQuery('document').ready(function(){
    jQuery('ul.treeview a').click(function(){
        li = jQuery(this).parent('li');
        if(li.find('ul').size()>0 && !li.hasClass('active'))
        {
            jQuery('ul.treeview li').removeClass('active');
            li.addClass('active');            
        }
        else{
            lnkObjectId = jQuery(this).attr('datafld');
            objRaiseEvent = jQuery('#'+lnkObjectId);
            //alert(lnkObjectId);
            if(objRaiseEvent!=null){
           // alert(jQuery(this).attr('datafld'));            
            href = objRaiseEvent.attr('href');
           // alert(href);
            href.replace('javascript:','');
            eval(href);
            }
        }
        return false;
    });
});
</script>
<asp:ObjectDataSource ID="CategoryDataSource" TypeName="AspNet.StarterKits.Classifieds.Web.CategoryCache"
    SelectMethod="GetAllCategories" runat="server"></asp:ObjectDataSource>
